//
//  HHButtonSample.swift
//  HHSwiftuiPractice
//
//  Created by HongMac on 2023/10/4.
//

import SwiftUI
import ToastUI

struct HHButtonSample: View {
    
    @State var title:String = "默认标题"
    let frText = "点击了"
    
    @State private var presentingToast: Bool = false
    
    var body: some View {
        VStack{
            
            Text(title)
                .font(.title2)
                .foregroundColor(.black)
                
            
            
            Button {
                title = "\(frText)Button #1"
                presentingToast = true
            
            } label: {
                Text("Button #1")
                    .font(.subheadline)
                    .foregroundColor(.white)
                    .padding()
                    .frame(maxWidth: .infinity)
                    .background(Color.blue)
                    .cornerRadius(10)
                    
            }
            .padding()
            .toast(isPresented: $presentingToast,dismissAfter: 2.0) {
//                    ToastView("Loading...")
//                           .toastViewStyle(.indeterminate)
                ToastView("666")

                }
            
            
            
            Button {
                title = "\(frText)Button #2"
            } label: {
                Circle()
               .fill(Color.white)
               .frame(width: 60,height: 60)
               .shadow(radius: 10)
               .overlay(
                   Image(systemName: "heart.fill")
                       .font(.title)
                       .foregroundColor(Color.red)
               )

            }
            
            Button {
                title = "\(frText)Button #3"
            } label: {
                Text("渐变色按钮")
                    .font(.title2)
                    .padding()
                    .foregroundColor(.black)
                    .padding(.horizontal, 20)
                    .background(
                        LinearGradient(colors: [.orange,.yellow], startPoint: .topLeading, endPoint: .bottomTrailing)
                    )
                    .cornerRadius(20)
                
            }
            .padding()
            



            
        }
    }
}

struct HHButtonSample_Previews: PreviewProvider {
    static var previews: some View {
        HHButtonSample()
    }
}
